<template>
    <div class="guide hasFoot ">
        <HeaderNav3 :activeIndex="activeIndex"></HeaderNav3>
        <Contact></Contact>
        <Ad></Ad>
        <ul class="loanTransaction-item wrap">
            <li v-for="item in items">
            <router-link :to="{path:'/BusinessDetails',query:{id:item.id}}">
                <div class="l" style="width: 240px;
                height:180px;">
                    <img :src="item.more">
                </div>
                <div class="r">
                    <p>{{item.post_title}}</p>
                    <div class="con">
                        <span>{{item.published_time}}</span>
                        <p>{{item.post_excerpt}}</p>
                    </div>
                </div>
            </router-link>
            </li>  
        </ul>
        <div class="guide-page">
            <el-pagination
                layout="prev, pager, next"
                @current-change="handleCurrentChange"
                :total="totalCount"
                >
            </el-pagination>
        </div>
    </div>
        
</template>

<script>
import HeaderNav3 from "@/components/HeaderNav3.vue"
import Contact from '@/components/Contact.vue'
import Ad from '@/components/Ad.vue'
import { V1_NEWS_LIST } from "@/config/api"

export default {
	components:{
        Contact,
        Ad,
        HeaderNav3
	},
    activated(){ 
        this.$store.commit("IS_SHOW_ALERT",true)

    }, 
    methods:{
        getData(){
            this.$http.get(V1_NEWS_LIST+0+"/"+(this.currentPage|0)+"/"+9,{
            }).then(res=>{
                if(res.data.success){
                    this.items=res.data.infor.listItems;
                    this.totalCount = Math.ceil(res.data.infor.totalCount/9)*10;
                    this.items.map((item) => {

                        var da = item.published_time*1000;
                        da = new Date(da);
                        var year = da.getFullYear()+'年';
                        var month = da.getMonth()+1+'月';
                        var date = da.getDate()+'日';
                        item.published_time=[year,month,date].join('');
                    })
                }
            })
        },
        handleCurrentChange(page) {
            this.currentPage = page-1;
            this.getData();
        },  
        collect(item){
            item.type = item.type?0:1;
            // TODO 请求
        }      
    },
    data(){
        this.getData();
       return{
            "items":[],
            "totalCount":0,
             currentPage:0,
            "activeIndex":"5",  
          
       }
    },
   
}
</script>
<style lang="scss">
    @import "../style/loanTransaction";
</style>